package com.yonyou.ucf.mdf.app.isvdxq.other.model;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.gson.Gson;
import com.yonyou.ucf.mdf.app.isvdxq.other.entity.ProductEntity;
import com.yonyou.ucf.mdf.app.isvdxq.other.entity.ProductSpecEntity;
import com.yonyou.ucf.mdf.app.isvdxq.other.entity.UnitassistEntity;

import java.util.ArrayList;
import java.util.List;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ProductBean extends ProductEntity {
    @Override
    public String toString() {
        return new Gson().toJson(this);
    }

    private String ytenant;

    public String getYtenant() {
        return ytenant;
    }

    public void setYtenant(String ytenant) {
        this.ytenant = ytenant;
    }

    private Object name;
    public String getName() {
        if(name == null) return null;
        if(name instanceof String) return name.toString();
        else{
            NameBean obj = JSONObject.parseObject( JSONObject.toJSONString(name), NameBean.class );
            return obj.getZh_CN();
        }
    }
    public void setName(Object name) {
        NameBean obj = new NameBean();
        if(name instanceof String) {
            obj.setZh_CN(name.toString());
        }
        else{
            obj = JSONObject.parseObject( JSONObject.toJSONString(name), NameBean.class );
        }
        this.name = obj;
        this.setProductName(obj.getZh_CN());
    }


    //辅助计量单位2
    private List<UnitassistEntity> productTplAssistUnitExchanges = new ArrayList<>();

    public List<UnitassistEntity> getProductTplAssistUnitExchanges() {
        return productTplAssistUnitExchanges;
    }

    public void setProductTplAssistUnitExchanges(List<UnitassistEntity> productTplAssistUnitExchanges) {
        this.productTplAssistUnitExchanges = productTplAssistUnitExchanges;
    }

    //辅助计量单位
    private List<UnitassistEntity> productAssistUnitExchanges = new ArrayList<>();

    public List<UnitassistEntity> getProductAssistUnitExchanges() {
        return productAssistUnitExchanges;
    }

    public void setProductAssistUnitExchanges(List<UnitassistEntity> productAssistUnitExchanges) {
        this.productAssistUnitExchanges = productAssistUnitExchanges;
    }
    //物料SKU
    private List<ProductTempSKUBean> productskus = new ArrayList<>();

    public List<ProductTempSKUBean> getProductskus() {
        return productskus;
    }

    public void setProductskus(List<ProductTempSKUBean> productskus) {
        this.productskus = productskus;
    }
    //物料规格
    private List<ProductSpecEntity> productspecitems = new ArrayList<>();

    public List<ProductSpecEntity> getProductspecitems() {
        return productspecitems;
    }

    public void setProductspecitems(List<ProductSpecEntity> productspecitems) {
        this.productspecitems = productspecitems;
    }
}
